package com.nineclock.auth.exception;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;

/**
 * @author 黑马程序员
 * @Company http://www.ithiema.com
 * @Version 1.0
 */
public class NcJsonSerializer extends JsonSerializer<NcOauth2Exception> {

    @Override
    public void serialize(NcOauth2Exception e, JsonGenerator gen, SerializerProvider serializers) throws IOException {
        gen.writeStartObject();
        gen.writeObjectField("success", "false");
        gen.writeObjectField("code", e.getHttpErrorCode());
        gen.writeObjectField("message", e.getMessage());
        gen.writeEndObject();
    }
}
